package com.panda.common.util;

import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.Date;
import java.util.TreeMap;

public class MyMap extends TreeMap<String, Object> {

		private static final long serialVersionUID = -6956263786920472107L;

		public MyMap() {
			super(String.CASE_INSENSITIVE_ORDER);
		}
		
		public Object put(String key, Object value) {
			return super.put(key.toUpperCase(), value);
		}
		
		public Object get(String key) {
			return super.get(key.toUpperCase());
		}
		
		public Object getObject(String key) {
			return get(key);
		}
		public String getString(String key) {
			Object o = get(key);
			if (o != null)
				return o.toString();
			else
				return null;
		}
		
		public Integer getInt(String key) {
			Object o = get(key);
			if (o == null)
				return 0;
			return Integer.parseInt(o.toString());
		}
		
		public Double getDouble(String key) {
			Object o = get(key);
			if (o == null)
				return 0d;
			if (o instanceof BigDecimal)
				return ((BigDecimal) o).doubleValue();
			return Double.parseDouble(o.toString());
		}
		
		
		public Short getShort(String key) {
			Object o = get(key);
			if (o == null)
				return 0;
			if (o instanceof Integer)
				return ((Integer) o).shortValue();
			else
				return (Short) get(key);
		}
		
		public Timestamp getTimestamp(String key) {
			return (Timestamp) get(key);
		}
		
		public BigDecimal getBigDecimal(String key) {
			return (BigDecimal) get(key);
		}
		
		public Date getDate(String key){
			return (Date) get(key);
		}
	}